<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of simulasi_model
 *
 * @author miyzan
 */
class simulasi_model extends MY_MODEL {

    //put your code here

    function __construct() {
        parent::__construct();
        // $this->load->database();
    }
    
    public function get_thajaran_aktif()
    {        
        $result = $this->callFunction('get_th_ajaran_aktif',array());
        return $result;
    }
    public function get_semester_aktif($idth)
    {        
        $result = $this->callFunction('get_semester',array($idth));
        return $result;
    }
    
    public function get_piutang_aktif($nis,$thajaran){
        $sql_search="nis = '$nis' and id_th_ajaran = '$thajaran'";        
        $select="id_piutang_siswa, thbl, nis, kd_kelas, kelas, id_th_ajaran, tahun_ajaran, semester, 
            kd_biaya, biaya, biaya_dikenakan, detail_potongan, total_potongan, total_biaya, saldo,
            jumlah_bayar as jumlah_bayar, pelunasan, id_jenis, jenisbiaya, no_rek, fgroup, pilih";
        $order=array("id_jenis,thbl,kd_biaya", "asc");     
        $table="v_piutang_aktif";
        
        $results = $this->get_rows_table($sql_search, $table, $select, $order);
        return $results; 
    }
    public function get_piutang_aktif2($nis){
        $sql_search="nis = '$nis'";        
        $select="id_piutang_siswa, thbl, nis, kd_kelas, kelas, id_th_ajaran, tahun_ajaran, semester, 
            kd_biaya, biaya, biaya_dikenakan, detail_potongan, total_potongan, total_biaya, saldo,
            jumlah_bayar as jumlah_bayar, pelunasan, id_jenis, jenisbiaya, no_rek, fgroup, pilih";
        $order=array("id_jenis,thbl,id_th_ajaran,kd_biaya", "asc");     
        $table="v_piutang_aktif";
        
        $results = $this->get_rows_table($sql_search, $table, $select, $order);
        return $results; 
    }
     
    
    function get_potongan_piutang($nis,$thbl,$kdbiaya){
        $sql_search = "nis = '$nis' and kd_biaya = '$kdbiaya' and thbl = $thbl";        
        $select="thbl, nis, id_th_ajaran, kd_biaya, biaya, potongan, keterangan";
        $order=array("kd_biaya,thbl", "asc");     
        $table="v_gen_piutang_pot";
        
        $results = $this->get_rows_table($sql_search, $table, $select, $order);
        return $results;       
        
    }
    
    function get_master_biaya() {
        $select="kd_biaya, keterangan, jenis_keterangan, no_rek,orderset";        
        $order=array("orderset", "asc");  
        $table="v_masterbiaya";
        $this->db->select($select);
//        $this->db->where("orderset not in (15)");
        $this->db->order_by($order[0], $order[1]);
        $query = $this->db->get($table);

        $rows = array();
        $total = 0;
        if ($query->num_rows() > 0) {
            $rows = $query->result();
            $total = $query->num_rows();
        }
        return $rows;       
        
    }  

}

?>
